var _ = require("lodash");
// _.intersectionBy([arrays], [iteratee=_.identity])
// 这个方法类似_.intersection，区别是它接受一个 iteratee 调用每一个arrays的每个值以产生一个值，
// 通过产生的值进行了比较。结果值是从第一数组中选择。iteratee 会传入一个参数：(value)

let a = _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
console.log(a);

let b = _.intersectionBy([{ x: 1 }], [{ x: 2 }, { x: 1 }], "x");
console.log(b);

let brr = [
  { name: "tom", age: "18" },
  { name: "tom2", age: "28" },
  { name: "tom3", age: "38" },
];
let brr2 = [
  { name: "tom4", age: "48" },
  { name: "tom2", age: "28" },
  { name: "tom5", age: "58" },
];
let brr3 = [
  { name: "tom6", age: "68" },
  { name: "tom2", age: "28" },
  { name: "tom7", age: "78" },
];

let c = _.intersectionBy(brr, brr3, brr2, "name");
console.log(c);
